<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <th:block th:include="/common/lib :: lib"></th:block>
    <script>
        function deleteData(id){
            util.ajaxFun("/back/article/delete",{"id":id},function (data) {
                util.jump("/back/article/list");
            });
        }
        function updateState(id,status) {
            util.ajaxFun("/back/article/updateState",{"id":id,"status":status},function (data) {
                util.jump("/back/article/list");
            });
        }
    </script>
</head>
<body class="">

    <div th:replace="/common/header :: header"></div>

    <div class="container content-main">
        <div class="row">
            <div class="col-lg-3 hidden-md hidden-xs hidden-sm border-right-1">
                <div th:replace="/common/back_left :: back_left"></div>
            </div>
            <div class="col-lg-9 col-md-12 col-sm-12 ">
                <div class="widget ">
                    <h4 class="title">文章内容</h4>
                    <div class="table-responsive">
                        <div class="btn-group" role="group" aria-label="...">
                            <a href="/back/article/add" class="btn btn-default">新增</a>
                        </div>
                        <table class="table table-striped ">
                            <thead>
                            <tr>
                                <th nowrap="">文章标题</th>
                                <th nowrap="">文章类型</th>
                                <th nowrap="">状态</th>
                                <th nowrap="">创建时间</th>
                                <th nowrap="">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="article : ${articleList}">
                                <td th:text="${article.title}"></td>
                                <td th:text="${article.contentType}"></td>
                                <td th:switch="${article.status}">
                                    <span th:case="0" class="label label-default">未发布</span>
                                    <span th:case="1" class="label label-success">已发布</span>
                                </td>
                                <td th:text="${#dates.format(article.createDate, 'yyyy-MM-dd HH:mm')}"></td>
                                <td>
                                    <a th:href="@{'/back/article/edit?id='+${article.id}}" th:if="${article.status != 1}" class="label label-primary">修改</a>
                                    <a href="#" th:if="${article.status != 1}" th:onclick="'javascript:updateState('+${article.id}+',1)'" class="label label-primary">发布</a>
                                    <a href="#" th:if="${article.status == 1}" th:onclick="'javascript:updateState('+${article.id}+',0)'" class="label label-primary">撤销</a>
                                    <a href="#" th:if="${article.status != 1}" th:onclick="'javascript:deleteData('+${article.id}+')'" class="label label-primary">删除</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <nav aria-label="...">
                        <ul class="pager">
                            <li><a th:href="@{/back/article/list(pageNum=(${pageNum}-1))}" th:if="${hasPrev}">上一页</a></li>
                            <li><a th:href="@{/back/article/list(pageNum=(${pageNum}+1))}" th:if="${hasNext}">下一页</a></li>
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
    </div>
</body>
</html>